package org.front.client.widget.mainwidget.event;

import org.front.client.utils.BaseEvent;

/**
 * 
 */
public class MainWidgetEvent extends BaseEvent<MainWidgetHandler> {

	/**
	 * Context associated to this event Put all needed informations into this object
	 */
	public static class Context extends BaseEvent.Context {

		/**
		 * Action
		 */
		public static enum Action {
			NONE, AFFICHER_DISTRIBUTEUR, AFFICHER_TRANSACTION, AFFICHER_MEILLEUR_PRODUIT, AFFICHER_BENEFICE_MOIS,
		}

		/**
		 * the action realized on the widget
		 */
		private Action action = Action.NONE;

		public void setAction(final Action action) {
			this.action = action;
		}

		public Action getAction() {
			return this.action;
		}
	}

	/** TYPE of this event */
	public static final Type<MainWidgetHandler> TYPE = new Type<MainWidgetHandler>();

	/**
	 * Default constructor in which a defautl context is already defined
	 */
	public MainWidgetEvent() {
		super(new Context());
	}

	/**
	 * Obtain the GwtEvent.Type of this event
	 * @return the type of this event
	 */
	public com.google.gwt.event.shared.GwtEvent.Type<MainWidgetHandler> getAssociatedType() {
		return TYPE;
	}

	/**
	 * Obtain the context associated to this event. First Call to this method return a non null Context that can be used.
	 * @return the Context of this event
	 */
	public Context getContext() {
		return (Context) super.getContext();
	}

	/**
	 * Dispatch event to handler
	 * @param handler handler
	 */
	protected void dispatch(final MainWidgetHandler handler) {
		handler.onMainWidget(this);
	}

}
